package agents;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;

import agents.resources.DriverUpdatePoints;
import aglobe.container.agent.Agent;
import aglobe.container.transport.Address;
import aglobe.ontology.AgentInfo;
import aglobe.ontology.Message;
import aglobe.ontology.MessageConstants;
import model.info.Constants;
import model.Model;
import view.MainGUI;
import controller.Controller;

public class SimulationAgent extends Agent {
	
	private Model model;
	private Controller controller;
	private MainGUI application;
	
	public void init(AgentInfo info,int initState) {
		
		model = new Model(this);
		controller = new Controller(model);
		application = new MainGUI(controller,info.getReadableName());
		//application.setExtendedState(PrincipalGUI.MAXIMIZED_BOTH);
		Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
		application.setLocation((dimension.width - application.getWidth()) / 2, (dimension.height - application.getHeight())/2);
	}
	
	public void handleIncomingMessage(Message message) {
		
	}

	public void finishTraffic(TrafficAgent trafficGenerator) {
		
		Message sms = Message.newInstance();
		sms.setPerformative(MessageConstants.INFORM);
		sms.setSender(getAddress());
		sms.setReceiver(trafficGenerator.getAddress());
		sms.setContent(Constants.KILL);
		try {
			this.sendMessage(sms);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
